import request from '@/utils/request_miva_work.js';

export function createArchive() {
  return request({
    url: '/audioArchive',
    method: 'POST'
  });
}

export function getArchiveList({ page = 1, size = 20, state } = {}) {
  return request({
    url: '/audioArchive',
    method: 'GET',
    params: { page, size, state }
  });
}

export function getArchive({ id }) {
  return request({
    url: '/audioArchive/' + id,
    method: 'GET'
  });
}

export function setArchive({ id, title, desc, state }) {
  return request({
    url: '/audioArchive/' + id,
    method: 'PUT',
    data: { title, desc, state }
  });
}

export function delArchive({ id }) {
  return request({
    url: '/audioArchive/' + id,
    method: 'DELETE'
  });
}

export function createAudioResource(archive_id, sort, resourceInfo) {
  return request({
    url: '/audioResource',
    method: 'POST',
    data: { archive_id, sort, resourceInfo }
  });
}
// export function createAudioResource({ aid, p, name, url, size, sign, mime, suffix }) {
//   return request({
//     url: '/audioResource',
//     method: 'POST',
//     data: { aid, p, name, url, size, sign, mime, suffix }
//   });
// }

export function editAudioResource(id, resourceInfo) {
  return request({
    url: '/audioResource/' + id,
    method: 'PUT',
    data: { resourceInfo }
  });
}
/**
 *
 * @param {[{id:number,sort:number}]} sortData 排序规则
 */
export function sortAudioResource(sortData) {
  return request({
    url: '/sortAudioResource',
    method: 'PUT',
    data: { sortData }
  });
}

export function deleteAudioResource({ id }) {
  return request({
    url: '/deleteAudioResource/' + id,
    method: 'DELETE'
  });
}

export function getHistoryEditArchive() {
  return request({
    url: '/audioArchiveHistory',
    method: 'GET'
  });
}
